<?php

class Application_Form_CreateUserForm extends Zend_Form
{
    public function getHakakses()
    {
        $hak_akses = new Application_Model_Hakakses();
        $hak_akses = $hak_akses->fetchAll();
        $hak = array();
        foreach ($hak_akses as $hak_akses)
        {
            $hak[$hak_akses->id_hak_akses] = $hak_akses->nama_hak_akses;    
        }
        
        return $hak;
    }
    
    public function init()
    {
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('Username')->setRequired();
        
        $old_password = new Zend_Form_Element_Password('old_password');
        $old_password->setLabel('Old Password')->setRequired();
        
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Password')->setRequired();
        
        $confpassword = new Zend_Form_Element_Password('repassword');
        $confpassword->setLabel('Confirm Password')->setRequired();
        
        $hak_akses = new Zend_Form_Element_Select('id_hak_akses');
        $hak_akses->setLabel('Access Previlages')->setRequired()->setMultiOptions($this->getHakakses());
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Add User');
        
        $ulang = new Zend_Form_Element_Button('ulang');
        $ulang->setLabel('Cancel')->removeDecorator('DtDdWrapper');
        
        $this->addElements(array($username, $old_password, $password, $confpassword, $hak_akses, $submit, $ulang));
    }


}

